<template>
  <zh-app>
    <view class="t-login">
      <!-- 页面装饰图片 -->
      <image class="img-a" src="./static/2.png"></image>
      <image class="img-b" src="./static/3.png"></image>
      <!-- 标题 -->
      <view class="content-title">{{ state.title }}</view>
      <view style="margin: 0rpx 60rpx">
        <Account v-if="state.loginType === 'username'"></Account>
        <Mobile v-if="state.loginType === 'cellphone'"></Mobile>
        <view class="flex-row-center-between" style="padding: 20rpx 0rpx 0rpx 0rpx">
          <zh-text style="z-index: 2" :margin="[0, 0]" :padding="[0, 0]" color="primary" :label="state.loginTypeName" @tap="loginTypeChange"></zh-text>
          <zh-text style="z-index: 2" :margin="[0, 0]" :padding="[0, 0]" color="primary" label="忘记密码" @tap="gotoForget"></zh-text>
        </view>
      </view>
      <view class="cardBox">
        <view class="flex-row-center-center">
          <zh-text style="z-index: 2" label="还没有登录账号？"></zh-text>
          <zh-text style="z-index: 2" color="primary" label="立刻注册"></zh-text>
        </view>
      </view>
    </view>
  </zh-app>
</template>
<script lang="ts" setup name="login1">
import { ref, reactive, onMounted } from 'vue';
import Account from './component/account.vue';
import Mobile from './component/mobile.vue';
// ------------------接收传入参数(组件)-------------------

// ------------------钩子函数----------------------------
// 初始化
onMounted(() => {});

// ------------------变量区------------------------------
const state = reactive({
  title: '欢迎回来',
  loginTypeName: '手机快捷登录',
  loginType: 'username',
});
// ------------------方法区------------------------------
const loginTypeChange = () => {
  if (state.loginType == 'username') {
    loginCode();
  } else {
    loginPhone();
  }
};
const loginCode = () => {
  state.loginType = 'cellphone';
  state.loginTypeName = '密码登录';
};
const loginPhone = () => {
  state.loginType = 'username';
  state.loginTypeName = '手机快捷登录';
};
const gotoForget = () => {
  $router.push('/pages/system/login/login1/forgetPassword',{});
};
</script>
<style lang="scss" scoped>
.img-a {
  position: absolute;
  width: 100%;
  top: -180rpx;
  right: -80rpx;
  z-index: 1;
}
.img-b {
  position: absolute;
  width: 50%;
  bottom: 0;
  left: -50rpx;
  z-index: 1;
}
.t-login {
  width: 100%;
  margin: 0 auto;
  font-size: 28rpx;
  color: #000;
  background-color: #ffffff;
  height: 100vh;
}
.t-login .content-title {
  text-align: left;
  font-size: 46rpx;
  color: #000;
  padding: 220rpx 0 120rpx 60rpx;
  font-weight: bold;
}
.cardBox {
  position: absolute;
  width: 100%;
  bottom: 100rpx;
  z-index: 2;
}
</style>
